import { memo } from "react";
import type { NodeProps } from 'reactflow'

import { NodeComponentMap } from "./constants";
import BaseNode from "./_base/base-node";

export type constWorkflowNodeProps = NodeProps

const _WorkflowNode = (props: constWorkflowNodeProps) => {
    let type: string | any = props.data?.type;
    if (!type) {
        type = props.type;
    }
    const NodeComponent = NodeComponentMap[type]

    return (
        <BaseNode {...props} >
            {
                NodeComponent && <NodeComponent />
            }
        </BaseNode>
    )
}

export const WorkflowNode = memo(_WorkflowNode);
export default WorkflowNode